package com.itheima.tanhua.vo;

import com.itheima.tanhua.domain.UserInfo;
import com.itheima.tanhua.mongo.UserLike;
import com.itheima.tanhua.mongo.Visitors;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;

/**
 * @author Lff
 * @date 2022/4/4
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class UserVo implements Serializable {
    private Long id; //用户id
    private String avatar;//头像
    private String nickname;//昵称
    private String gender;//性别
    private Integer age;//年龄
    private String city;//所在地
    private String education;//学历
    private Integer marriage;//是否结婚
    private Integer matchRate = 0;//缘分值
    private boolean alreadyLove = false;//是否互相喜欢

    /**
     * 关注 喜欢 粉丝
     * @param userInfo
     * @param userLike
     * @return
     */
    public static UserVo initUserLike(UserInfo userInfo, UserLike userLike) {
        UserVo userLikeVo = new UserVo();
        BeanUtils.copyProperties(userInfo, userLikeVo);
        userLikeVo.setAlreadyLove(userLike.getAlreadyLove());
        return userLikeVo;
    }

    /**
     * 谁看过我
     * @param userInfo
     * @param visitors
     * @return
     */
    public static UserVo initVisitors(UserInfo userInfo, Visitors visitors) {
        UserVo userLikeVo = new UserVo();
        BeanUtils.copyProperties(userInfo, userLikeVo);
        userLikeVo.setMarriage(visitors.getScore().intValue());
        return userLikeVo;
    }
}
